package com.fs.model;

import com.fs.util.FATUtil;
import lombok.*;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class DiskBlock {
    private int no;//盘块号
    private int index;//下一个磁盘盘块索引
    private String type;//类型，文件，文件夹，空
    private boolean begin;//代表是否为文件的起始磁盘
    private Object object;//代表文件或者文件夹对象,即指向这个磁盘块属于的文件或文件夹


    public DiskBlock(int no,int index,String type,Object object) {
        this.no=no;
        this.index=index;
        this.type=type;
        this.object=object;
        this.begin=false;
    }
    public boolean isFree() {
        return index == 0;
    }

    public void allocBlock(int index, String type, Object object, boolean begin) {
        setIndex(index);
        setType(type);
        setObject(object);
        setBegin(begin);
    }
    public void clearBlock() {
        setIndex(0);
        setType(FATUtil.EMPTY);
        setObject(null);
        setBegin(false);
    }
}
